package com.example.rocketmqspringbootdemo.service.consumer;

import com.example.rocketmqspringbootdemo.CommonConstrant;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Service;

//一个消费者Group ID下所有Consumer实例所订阅的Topic、Tag必须完全一致（内容和顺序都要相同）,否则会导致消息消费的逻辑就会混乱，甚至导致消息丢失
@Service
@RocketMQMessageListener(topic = CommonConstrant.RocketMQ.STRING_TOPIC,
        consumerGroup = CommonConstrant.RocketMQ. STRING_CONSUMER_TAG_GROUP,
        messageModel = MessageModel.CLUSTERING,
        selectorExpression =  CommonConstrant.RocketMQ.TAG_STRING)
public class StringTopicWithTagConsumer1 implements RocketMQListener<String> {
    @Override
    public void onMessage(String message) {
        System.out.println("[STRING_TOPIC_TAG1]received: " + message);
    }
}
